package com.kyxx.mycommonproject.shanping;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.kyxx.mycommonproject.MainActivity;
import com.kyxx.mycommonproject.R;
import com.kyxx.mycommonproject.base.BaseActivity;
import com.kyxx.mycommonproject.shanping.presenter.SplashPresenter;
import com.kyxx.mycommonproject.shanping.view.ISplashView;

/**
 * Created by GQI on 2016/9/8.
 */
public class SplashActivity extends BaseActivity implements ISplashView{
    private ImageView mSplashItem_iv;
    private SplashPresenter presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        mSplashItem_iv = (ImageView) findViewById(R.id.splash_loading_item);
        /** 闪屏广告p层初始化*/
        presenter = new SplashPresenter(this);
        /** 闪屏广告p层开始方法*/
        presenter.start();
    }

    /**
     * 动画效果
     * */
    @Override
    public void startLoadingAdmin() {
        Animation translate = AnimationUtils.loadAnimation(this,
                R.anim.splash_loading);
        translate.setAnimationListener(new Animation.AnimationListener() {

            @Override
            public void onAnimationStart(Animation animation) {
            }

            @Override
            public void onAnimationRepeat(Animation animation) {
            }

            @Override
            public void onAnimationEnd(Animation animation) {
                overridePendingTransition(0, 0);
                presenter.toActivity();
            }
        });
        mSplashItem_iv.setAnimation(translate);
    }

    @Override
    public void startActivity() {
        startActivity(MainActivity.class);
        this.finish();
    }
}
